namespace Gamov.Net6.ConsoleProject.HostServices
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    using Gamov.Net6.ConsoleProject.Models.Config;
    using Gamov.Net6.Framework.Attributes;
    using Microsoft.Extensions.Hosting;
    using Microsoft.Extensions.Logging;
    using Microsoft.Extensions.Options;

    [HostService]
    public class InitHostService : BackgroundService
    {
        private readonly ILogger<InitHostService> _logger;
        private readonly TestConfig _testConfig;

        public InitHostService(
            ILogger<InitHostService> logger,
            IOptions<TestConfig> testConfig)
        {
            _logger = logger;
            _testConfig = testConfig.Value;
        }

        protected override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            _logger.LogInformation("123");
            _logger.LogInformation(_testConfig.MyProperty);
            return Task.CompletedTask;
        }
    }
}
